Ext.namespace("NewCustomer");

NewCustomer.Imp = function(p) {
	this.parentWin=p;
	
	this.hdIssueId = new Ext.form.Hidden({name:'issueId'});
	this.txtIssueTitle = new Ext.form.TextField({
		fieldLabel: '问题标题',
		name:'issueTitle',
		disabled:true,
		width: 380
	});
	this.txtManagerId=new Ext.form.Hidden({name:'managerId'});
	this.txtManagerName = new Ext.form.TextField({
		fieldLabel: '受理领导',
		name:'managerName',
		width: 150,
		disabled: true
	});
	this.txtReportDept =new Ext.form.Hidden({name:'reportDept'});	
	this.txtIssueContent = new Ext.form.TextArea({
		fieldLabel: '问题描述',
		name:'issueContent',
		disabled:true,
		height:50,
		width: 380
	});
	this.typeStore  = new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: [[1, '第三方平台终端缺货问题'],[2, '集采平台终端缺货问题'],[3, '终端设备类问题'],
        		[4, 'SIM卡类问题'],[5, '重点营销活动界面反映问题'],[6, '客户投诉及一线客户服务需求问题'],
        		[7, '生产运营设备情况'],[8, '后勤支撑'],[9, '员工队伍情况'],[10, '市场信息'],[11, '其他']]
    });
	this.txtIssueType = new Ext.form.ComboBox({
		width: 150,
		fieldLabel: '问题类别',
		name:'issueType',
		store: this.typeStore,
		value:"1",	
        valueField: 'value',
        displayField: 'name',
        editable: false,
        disabled:true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true
	});
	this.dtIssueDate = new Ext.form.DateField({
    	fieldLabel: '提问时间',
    	name:'issueDate',
    	disabled:true,
		width: 150,
		format: 'Y-m-d'
	});
	this.typeLebel  = new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: [[0, '普通'],[1, '急'],[2, '特急']]
    });
	this.txtInstancyLevel = new Ext.form.ComboBox({
		width: 150,
		fieldLabel: '紧急程度',
		name:'instancyLevel',
		store: this.typeLebel,
		value:"0",	
        valueField: 'value',
        displayField: 'name',
        editable: false,
        disabled:true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true
	});
	this.txtCreateName = new Ext.form.TextField({
		fieldLabel: '填报人',
		name:'createName',
		width: 150,
		disabled:true
	});
	this.txtDeptName = new Ext.form.TextField({
		fieldLabel: '营业厅',
		name:'deptName',
		width: 150,
		disabled:true
	});
	this.form = new Ext.FormPanel({
		bodyStyle: 'padding: 5px 5px 0',
        labelWidth: 70,
        labelAlign: 'right',
        items: [ this.txtIssueTitle,
        	this.txtIssueContent,{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .50, items: [this.txtIssueType]},
	        	         { columnWidth: .50, items: [this.dtIssueDate]}]
	    				},{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .50, items: [this.txtManagerName]},
	        	         { columnWidth: .50, items: [this.txtInstancyLevel]}]
	    	},{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .50, items: [this.txtCreateName]},
	        	         { columnWidth: .50, items: [this.txtDeptName]}]
	    	},this.txtManagerId,this.txtReportDept,this.hdIssueId	    	
	    	]
    });	
    this.btnSave = new Ext.Button({
    	text:'保存',
    	handler:this.onSave,
    	scope: this
    });
	NewCustomer.Imp.superclass.constructor.call(this, {
		title: '厅问题督办',
        autoHeight: false,
        width: 500,
        y: 20,
        resizable: false,
        plain: true,
        modal: true,
        autoScroll: true,
        closeAction: 'hide',
        items: [this.form],
        buttons: [this.btnSave,{
            text: '关闭',
            scope: this,
            handler: function() {
	        	this.hide();
        	}
        }],
        buttonAlign:'center'
	});
};
Ext.extend(NewCustomer.Imp, Ext.Window, {
	initWin:function(data){
		this.form.getForm().setValues(data);
	},
	onSave: function() {
		if(!this.form.getForm().isValid()){
			Utils.info2("有必填项没有填写，请检查！",180);
			return;
		}
		var conn = new Ext.data.Connection({
  			url:'../superviseIssue/addSupervise.form?timesnap=' + Date.parse(new Date()),
  			method:'post'
  		})
  		var param={workId:this.hdIssueId.getValue(),
  					managerId:this.txtManagerId.getValue()};
  		//alert(Ext.util.JSON.encode(param));
		Utils.request(conn,{
  			params:param,
  			scope:this,
  			success:function(data){
  				Utils.info2();
				this.scope.hide();
				this.scope.parentWin.queryIssue();
  			}
  		});
	}
});

